package javatwo.annotation.course2.ejb31;

import javax.ejb.ConcurrencyManagement;
import javax.ejb.ConcurrencyManagementType;
import javax.ejb.Lock;
import javax.ejb.LockType;
import javax.ejb.Singleton;
import javax.ejb.Stateless;

@Singleton
@ConcurrencyManagement(ConcurrencyManagementType.CONTAINER)
//@Stateless
public class SingletonBean {

	private int clickCount = 0;

	//@Lock(LockType.READ)
	public int getClickCount() {

		// pause 10 sec
//		try {
//			Thread.currentThread().sleep(10000);
//		} catch (InterruptedException e) {
//			e.printStackTrace();
//		}

		return clickCount;
	}

	//@Lock(LockType.WRITE)
	public void addClickCount() {
		clickCount++;
	}
}
